package graphics;

import graphics.tools.PickObject;

import java.awt.GraphicsConfiguration;

import javax.media.j3d.Canvas3D;

import com.sun.j3d.utils.universe.SimpleUniverse;

/**
 * Class for Canvas3D creation
 * 
 * @author: Eirik Vigeland
 * @version: %I%, %G%
 */
public class Universe extends Canvas3D {
	
	private static final long serialVersionUID = 1L;
	private SimpleUniverse su;
	private SceneGraph bg;
	
	/**
	 * Constructor setting up the Canvas3D for displaying the Universe
	 * 
	 * @param gc
	 *            GrpahicConfigurations of SimpleUniverse
	 */
	public Universe(GraphicsConfiguration gc) {
		super(gc);
		su = new SimpleUniverse(this);
		su.getViewingPlatform().setNominalViewingTransform();
		bg = new SceneGraph(su, this);
		bg.compile();
		PickObject pc = new PickObject(this, bg);
		addMouseListener(pc);
		su.addBranchGraph(bg);
	}
	
	/**
	 * Returns the Scene graph
	 * 
	 * @return SceneGraph
	 */
	public SceneGraph getSceneGraph() {
		return bg;
	}

}
